﻿<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
    String filePath = request.getServletContext().getRealPath("/applicant/images/");
%>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>我的工作申请 - 锐聘网</title>
    <link href="<%=basePath%>/css/base.css" rel="stylesheet" type="text/css"/>
    <link href="<%=basePath%>/css/myapplys.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<iframe src="<%=basePath%>/top.jsp" width="100%" height="100" scrolling="no" frameborder="0"></iframe>
<div id="tn-content" class="tn-content-bg">
    <div class="tn-wrapper">
        <div class="tn-grid">
            <div class="it-content-box it-person">
                <div class="tn-box-content">
                    <div class="tn-tabs">
                        <ul class="tn-tabs-nav tn-widget-content ">
                            <li><a href="/itoffer/resume/selectCurrentResumeServlet">我的简历</a></li>
                            <li class="tn-tabs-selected"><a href="/itoffer/company/selectJobApply">我的申请</a></li>
                        </ul>
                        <div class="tn-tabs-panel tn-widget-content">
                            <form action="#" method="post" id="Form-Apply">
                                <table class="tn-table-grid">
                                    <tbody>
                                    <tr class="tn-table-grid-header">
                                        <th class="tn-width-check"><input type="checkbox" class="tn-checkbox"
                                                                          id="selectAll" name="selectall" onclick="funcOne()">
                                        </th>
                                        <th> 企业名称</th>
                                        <th class="it-text-ctnter"> 职位名称</th>
                                        <th class="it-text-ctnter"> 申请状态</th>
                                        <th></th>
                                    </tr>
                                    <c:forEach items="${jobApplyList}" var="item">
                                        <tr class="tn-table-grid-row">
                                            <td class="tn-width-check">
                                                <input type="checkbox" class="tn-checkbox tnui-apply" value="${item.apply_id}"
                                                       name="applyIdList"></td>
                                            <td class="tn-width-auto">
                                                <a title="${item.job_name}" href="#"
                                                   target="_blank"> ${item.company_name}</a>
                                            </td>
                                            <th class="tn-width-pic-mini">
                                                <a title="${item.job_name}" href="#"
                                                   target="_blank">${item.job_name}</a>
                                            </th>
                                            <td class="tn-width-category">
                                                <div class="tn-instructions">
                                                    <div class="it-instructions-tit">
                                                        <span style="width: 26px">申请</span>
                                                        <span style="width: 132px">审核</span>
                                                        <span style="width: 112px">通知</span>
                                                    </div>
                                                    <div class="tn-progress-bar tn-widget-content tn-corner-all">
                                                        <div style="width: 50%;"
                                                             class="tn-progress-bar-value tn-widget-header tn-corner-left tn-border-tbl"></div>
                                                    </div>
                                                    <ul class="tn-helper-clearfix tn-step-scale"></ul>
                                                </div>
                                            </td>
                                            <td class="tn-width-action2">
                          <span class="tn-action">
                              <a class="tn-action tn-action-text-icon tnui-apply-delete" href="deleteJobByApplyId?apply_id=${item.apply_id}">
                                  <span class="tn-icon it-icon-delete"></span>
                                  <span class="tn-action-text">删除</span>
                              </a>
                          </span>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </form>
                            <div class="it-page-results tn-helper-clearfix">
                                <div class="tn-helper-left"><a
                                        class="tn-button tn-corner-all tn-button-text-only tn-button-semidlong" href="#"
                                        id="deleteAll" onclick="dele()"> <span class="tn-button-text">删除</span></a></div>
                                <div class="tn-pagination tn-pagination-simple tn-helper-clearfix">
                                    <div class="tn-pagination-btn"><a href="#" class="tn-page-prev tn-page-thumb">上一页</a>
<%--                                        <span class="tn-page-number tn-selected">1</span>--%>
                                        <c:forEach  var="i" begin="1" end="${pages}">
                                        <a href="/itoffer/company/selectByPage?currentPage=${i}" class="tn-page-number">${i}</a>
                                        </c:forEach>

                                        <a href="#" class="tn-page-thumb tn-page-next">下一页</a></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
<iframe src="<%=basePath%>/foot.jsp" width="100%" height="150" scrolling="no" frameborder="0"></iframe>
<script src="/js/axios-0.18.0.js"></script>
<script type="text/javascript">

    var _arrays = [];
    //js实现全选
    function funcOne(){
        var selectAll = document.getElementById('selectAll');
        var selectOnes =  document.getElementsByName('applyIdList');
        if(selectAll.checked){
            for (var i=0;i<selectOnes.length;i++){
                selectOnes[i].checked = true;
                _arrays.push(selectOnes[i].value);
            }

        }else{
            for (var i=0;i<selectOnes.length;i++){
                selectOnes[i].checked = false;
                _arrays = [];
            }
        }
        console.log(_arrays)
    }

    var deleteAll = document.getElementById('deleteAll');
    function dele(){
       var arrays = _arrays;
        deleteAll.href = "/itoffer/company/deleteByIds?arrays="+arrays;
    }

    //获取当前url
    var url = window.location.href;
    console.log(url);

    //分割?右边url
    let p=url.split('?')[1];

    //使用URL查找参数方法
    let params=new URLSearchParams(p);
    //字符串转数字
    //console.log(typeof params.get('currentPage') )
    var _current = parseInt(params.get('currentPage'));

    var pageNumber = "";

    var yema = ${pages};
    //console.log(_current)
    //得到下一页对象
    var next = document.querySelector('.tn-page-next');

    //下一页点击事件
    next.onclick = function () {
        //console.log("1")
        //参数值加1
        if(_current < yema){
            _current++;
            pageNumber = ''+_current;
            //console.log(pageNumber)
            window.location.href ="selectByPage?currentPage="+ pageNumber
        }else if(_current==yema){
            alert("当前为最后一页");
        }
        //console.log(_current)
    }
    //得到上一页对象
    var prev = document.querySelector('.tn-page-prev');
    prev.onclick = function () {
        if(_current > 1){
            _current--;
            pageNumber = ''+_current;
            //console.log(pageNumber)
            window.location.href ="selectByPage?currentPage="+ pageNumber
        }else if(_current==1){
            alert("当前为第一页");
        }

    }

</script>
</body>
</html>
